package com.example.sxproject.mapper;

import com.example.sxproject.pojo.Card;
import com.example.sxproject.pojo.Recipient;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface RecipientMapper {

    //查询：根据所属用户查询
    @Select("select * from recipient where userId=#{userId}")
    List<Recipient> selectByUserId(Integer userId);

    //添加：添加一个收款人
    @Insert("insert into recipient" +
            "(id, cardId, recName, userId, status)" +
            " values (#{id}, #{cardId}, #{recName}, #{userId}, #{status})")
    void addRecipient(Recipient recipient);

    //更新：更新收款人信息
    @Update("update recipient set cardId = #{cardId}, recName = #{recName}," +
            "userId = #{userId}, status = #{status} " +
            "where id = #{id}")
    void updateRecipient(Recipient recipient);

    //更新：假删除
    @Update("update recipient set status = #{status} " +
            "where id = #{id}")
    void delete(Recipient recipient);


}

